﻿<controls:MetroWindow x:Class="Papercut.Views.RulesConfigurationView"
                      xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
                      xmlns:controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
                      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                      xmlns:model="clr-namespace:Papercut.ViewModels"
                      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                      xmlns:ViewModels="clr-namespace:Papercut.ViewModels"
                      xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
                      xmlns:behaviours="http://metro.mahapps.com/winfx/xaml/shared"
                      xmlns:cal="http://www.caliburnproject.org"
                      mc:Ignorable="d"
                      Title="{Binding WindowTitle}" Width="773" Height="400" Icon="/Papercut;component/App.ico"
                      WindowStyle="ToolWindow"
                      ResizeMode="CanResizeWithGrip"
                      ShowIconOnTitleBar="false" WindowStartupLocation="CenterOwner"
                      BorderThickness="{DynamicResource AccentBorderThickness}" 
                      GlowBrush="{DynamicResource AccentGlowBrush}"
                      BorderBrush="{DynamicResource AccentBorderBrush}">
    <DockPanel>
        <ToolBarTray Height="Auto" DockPanel.Dock="Top" Background="WhiteSmoke">
            <ToolBar Width="Auto" Margin="2">
                <Menu>
                    <MenuItem x:Name="RegisteredRules" Margin="1" Padding="8,4,8,4" cal:Message.Attach="AddRule($originalsourcecontext)">
                        <MenuItem.HeaderTemplate>
                            <DataTemplate>
                                <StackPanel Orientation="Horizontal">
                                    <Rectangle Width="20" Height="20" Fill="{Binding RelativeSource={RelativeSource AncestorType=MenuItem}, Path=Foreground}">
                                        <Rectangle.OpacityMask>
                                            <VisualBrush Stretch="Fill"
                                         Visual="{StaticResource appbar_layer_add}" />
                                        </Rectangle.OpacityMask>
                                    </Rectangle>
                                    <TextBlock Margin="4 0 0 0"
                               VerticalAlignment="Center"
                               Text="Add Rule" />
                                </StackPanel>
                            </DataTemplate>
                        </MenuItem.HeaderTemplate>
                        <MenuItem.ItemTemplate>
                            <DataTemplate>
                                <StackPanel Orientation="Horizontal">
                                    <Rectangle Width="20" Height="20" Fill="{Binding RelativeSource={RelativeSource AncestorType=MenuItem}, Path=Foreground}">
                                        <Rectangle.OpacityMask>
                                            <VisualBrush Stretch="Fill"
                                         Visual="{StaticResource appbar_box}" />
                                        </Rectangle.OpacityMask>
                                    </Rectangle>
                                    <TextBlock Margin="4 0 0 0" VerticalAlignment="Center" Text="{Binding Type}" />
                                </StackPanel>
                            </DataTemplate>
                        </MenuItem.ItemTemplate>
                    </MenuItem>
                    <Separator Style="{StaticResource {x:Static ToolBar.SeparatorStyleKey}}" Margin="4,2,4,2" />
                    <MenuItem Padding="8,4,8,4" Margin="1" cal:Message.Attach="DeleteRule" IsEnabled="{Binding HasSelectedRule}">
                        <MenuItem.HeaderTemplate>
                            <DataTemplate>
                                <StackPanel Orientation="Horizontal">
                                    <Rectangle Width="20" Height="20" Fill="{Binding RelativeSource={RelativeSource AncestorType=MenuItem}, Path=Foreground}">
                                        <Rectangle.OpacityMask>
                                            <VisualBrush Stretch="Fill"
                                         Visual="{StaticResource appbar_layer_minus}" />
                                        </Rectangle.OpacityMask>
                                    </Rectangle>
                                    <TextBlock Margin="4 0 0 0"
                               VerticalAlignment="Center"
                               Text="Delete Rule" />
                                </StackPanel>
                            </DataTemplate>
                        </MenuItem.HeaderTemplate>
                    </MenuItem>
                </Menu>
            </ToolBar>
        </ToolBarTray>
        <DataGrid x:Name="MessagesList" Width="Auto" Height="Auto" 
                  SelectedItem="{Binding SelectedRule,Mode=TwoWay}"
                  ItemsSource="{Binding Rules}" AutoGenerateColumns="False" IsReadOnly="True">
            <DataGrid.Columns>
                <DataGridCheckBoxColumn Header="Enabled" Binding="{Binding IsEnabled}" />
                <DataGridTextColumn Header="Rule Type" Binding="{Binding Type}" />
                <DataGridTextColumn Header="Description" Binding="{Binding Description}" />
            </DataGrid.Columns>
        </DataGrid>
        <xctk:PropertyGrid DockPanel.Dock="Right" Width="Auto" SelectedObject="{Binding SelectedRule}"></xctk:PropertyGrid>
    </DockPanel>
</controls:MetroWindow>